	function initRequest()
{
    var request = false;
    if(window.XMLHttpRequest) {         //FireFox
    request = new XMLHttpRequest();
    if (request.overrideMimeType) {
      request.overrideMimeType('text/xml');
    }
  }
  else if (window.ActiveXObject) {    //IE
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
  if (!request) {
    window.alert("Create request error!");
    return false;
  }
  return request;
}

	
function sent(sendUrl)
{
	var json;
	var http_request;
  http_request = initRequest();
 // alert("开始执行");
  sendUrl += "&random="+Math.random();   //在URL后添加这个，可以保证不被缓存
 
  //get
  http_request.open("GET", sendUrl,false);
  
  http_request.send(null);
  var str = http_request.responseText;//修改
  json=JSON.parse(str);   //修改
 //lert("json3"+json);
  return json;
  //post
  //http_request.open("POST", sendUrl, true);
  //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  //http_request.send(sendData);
}

function ajax_call_back()
{
    //readyState共有5中状态，0未初始化，1已初始化，2发送请求，3开始接收结果，4接收结果完毕。
    //status服务器响应状态码
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
     var str = http_request.responseText;
     //return str;
    
    //  console.log("test");
    }
    else if(http_request.status == 404){
      alert("请求资源不存在！");
    }
    else {
      alert("Ajax请求失败，错误状态为："+http_request.status);
    }
  }
  else
	  {
	  alert("sorry"+http_reuqest.readyState);
	  }
}


function holdfour(catagry)//获取不同种类电影的信息
{
	
var json=sent("http://localhost:8080/movieManager/mainpage.do?methodName="+catagry);	

return json;
}


